home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-12-04 | 2.3 KB | 98 lines | [TEXT/MPS ] |
- /*
- File: icm5.c
- Contains: Sequence Play Functions
- Written by: DTS and QT Engineering
- Copyright: © 1992-1994 by Apple Computer, Inc., all rights reserved.
- Change History (most recent first):
- <1> 12/4/94 khs changed the format of the file to the new look and feel
- To Do:
- */
-
-
- // INCLUDE FILES
- #include "icm.h"
-
-
- // FUNCTIONS
- void SequencePlay(void)
- {
- ImageDescriptionHandle description;
- long compressedSize;
- Handle buffer = nil;
- Ptr bufferAddr;
- long dataLen;
- long lastTicks;
- ImageSequence sequenceID;
- Rect imageRect;
- StandardFileReply fileReply;
- SFTypeList typeList =
- {
- 'SEQU', 0, 0, 0
- };
- short dfRef = 0; // sequence data fork
- short rfRef = 0; // sequence resource fork
- OSErr error;
-
- StandardGetFile(nil, 1, typeList, &fileReply);
- if (!fileReply.sfGood)
- return;
-
- rfRef = FSpOpenResFile(&fileReply.sfFile, fsRdPerm);
- CheckError(ResError(), "\pFSpOpenResFile");
-
- description = (ImageDescriptionHandle)Get1Resource('SEQU', 128);
- CheckError(ResError(), "\pGet1Resource");
-
- DetachResource((Handle)description);
- HNoPurge((Handle)description);
- CloseResFile(rfRef);
-
- error = FSpOpenDF(&fileReply.sfFile, fsRdPerm, &dfRef);
- CheckError(error, "\pFSpOpenDF");
-
- buffer = NewHandle(4);
- CheckError(MemError(), "\pNewHandle buffer");
-
- SetRect(&imageRect, 0, 0, (**description).width, (**description).height);
- error = DecompressSequenceBegin(&sequenceID, description, nil,// use the current port
- nil, // goto screen
- &imageRect, nil,// no matrix
- ditherCopy, nil,// no mask region
- codecFlagUseImageBuffer, codecNormalQuality,// accuracy
- (CompressorComponent)anyCodec);
-
- while (true)
- {
- dataLen = 4;
- error = FSRead(dfRef, &dataLen, &compressedSize);
- if (error == eofErr)
- break;
- CheckError(error, "\pFSRead");
-
- if (compressedSize > GetHandleSize(buffer))
- {
- HUnlock(buffer);
- SetHandleSize(buffer, compressedSize);
- CheckError(MemError(), "\pSetHandleSize");
- }
-
- HLock(buffer);
- bufferAddr = StripAddress(*buffer);
- error = FSRead(dfRef, &compressedSize, bufferAddr);
- CheckError(error, "\pFSRead");
-
- error = DecompressSequenceFrame(sequenceID, bufferAddr, 0,// flags
- nil, nil);
- CheckError(error, "\pDecompressSequenceFrame");
-
- Delay(30, &lastTicks);
- }
-
- CDSequenceEnd(sequenceID);
- FSClose(dfRef);
- DisposeHandle(buffer);
- DisposeHandle((Handle)description);
- }
-
-
-